-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addressing blocking issues from test plan for inferred tuple names #19016
Addressing blocking issues from test plan for inferred tuple names #19016
Conversation
I'm going through the test plan today, using the branch you prepared for this PR as a reference. #Resolved |
@gafter
|
5ad2722
to
62257a1
Compare
8b71d5e
to
dfa1b4b
Compare
|
||
var inferredPositions = inferNames ? tupleNames.SelectAsArray(n => n != null) : default(ImmutableArray<bool>); | ||
return new BoundTupleLiteral(syntax, tupleNames, inferredPositions, arguments: valuesBuilder.ToImmutableAndFree(), type: type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably save the positions even if it isn't in the type, however, this is probably not observable until we permit tuple element names on the left of a deconstruction.
Compilation, | ||
shouldCheckConstraints: false); | ||
shouldCheckConstraints: false, | ||
inferredPositions: inferredPositions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps should be language version dependence here.
Compilation, | ||
shouldCheckConstraints: false); | ||
shouldCheckConstraints: false, | ||
inferredPositions: inferredPositions); | ||
return new BoundTupleLiteral(syntax, default(ImmutableArray<string>), default(ImmutableArray<bool>), subExpressions, tupleType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And needs to be passed here I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a few noted suggestions.
Sorry, a number of my comments are in #19021 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…port errors on usage
563e43f
to
5176e5d
Compare
@dotnet-bot test windows_debug_vs-integration_prtest please |
@dotnet-bot test windows_release_vs-integration_prtest please |
@dotnet/roslyn-compiler Sorry, I forgot to tag the team on this. Let me know. |
} | ||
var uniqueFieldNames = PooledHashSet<string>.GetInstance(); | ||
RemoveDuplicateInferredTupleNames(namesBuilder, uniqueFieldNames); | ||
uniqueFieldNames.Free(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can uniqueFieldNames
be moved to RemoveDuplicateInferredTupleNames
as an implementation detail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, no. Two of the usages use a fresh hashset (because they can't have explicit names in those scenarios, for instance in deconstruction), but one needs a hashset that already has explicit names (that's in BindTupleExpression
).
@@ -47,13 +54,15 @@ internal sealed class TupleTypeSymbol : WrappedNamedTypeSymbol | |||
internal const string TupleTypeName = "ValueTuple"; | |||
internal const string RestFieldName = "Rest"; | |||
|
|||
private TupleTypeSymbol(Location locationOpt, NamedTypeSymbol underlyingType, ImmutableArray<Location> elementLocations, ImmutableArray<string> elementNames, ImmutableArray<TypeSymbol> elementTypes) | |||
private TupleTypeSymbol(Location locationOpt, NamedTypeSymbol underlyingType, ImmutableArray<Location> elementLocations, | |||
ImmutableArray<string> elementNames, ImmutableArray<TypeSymbol> elementTypes, ImmutableArray<bool> inferredNamesPositions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to call the parameter inferredNamesPositions
here rather than errorPositions
as elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a lapse. I'll fix in next PR.
@@ -210,10 +210,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols | |||
Inherits TupleElementFieldSymbol | |||
|
|||
Private _name As String | |||
Private _cannotUse As Boolean ' With LanguageVersion 15, we will produce named elements that should not be used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReadOnly
for both fields.
/// If none of the element names were inferred, or inferred names can be used (no tracking necessary), leave as default. | ||
/// This information is ignored in type equality and comparison. | ||
/// </summary> | ||
private readonly ImmutableArray<bool> _errorPositions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the _errorPositions
field only applies to use of inferred names at those positions, would it make sense to call this array _cannotUseInferredNames
?
LGTM |
This PR is not ready for review yet. I will add more tests as Neal goes through the test plan today and provides feedback.
Test plan #18606
FYI @gafter